<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="cn.weiyang.entity.Book"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
   table{
            border-collapse: collapse;
   }
   tr,th,td{
            border:1px solid;
   }
</style>
</head>
<body>
    <%
      Map<String,Book> bookMap=new HashMap<String,Book>();
      Book book1=new Book("a01","唐史",32.41);
      Book book2=new Book("a02","明史",21.31);
      Book book3=new Book("a03","宋史",35.27);
      Book book4=new Book("a04","汉史",42.15);
      bookMap.put(book1.getIsbn(),book1);
      bookMap.put(book2.getIsbn(),book2);
      bookMap.put(book3.getIsbn(),book3);
      bookMap.put(book4.getIsbn(),book4);
      request.setAttribute("bookMap", bookMap);
    %>
    <table>
          <tr>
             <th>编号</th>
             <th>书名</th>
             <th>单价</th>
          </tr>
    
    <s:iterator id="book" value="#request.bookMap" status="st">
       <s:if test="#st.odd">
          <tr bgcolor="yellow">
       </s:if>
       <s:else>
          <tr bgcolor="cyan">
       </s:else>
             <td><s:property value="#book.key"/></td>
             <td><s:property value="#book.value.name"/></td>
             <td><s:property value="#book.value.price"/></td>
           </tr>
    </s:iterator>
    </table>
</body>
</html>